﻿import java.util.Scanner;

public class HomeWork {
	Scanner input = new Scanner(System.in);
	public double triangle(){
		System.out.println("请输入三角形的三条边长：");
		double a = input.nextDouble();
		double b = input.nextDouble();
		double c = input.nextDouble();
		double p = (a+b+c)/2;
		double s = Math.sqrt(p*(p-a)*(p-b)*(p-c));
		return s;
	}

	public double rectangle(){
		System.out.println("请输入矩形的长：");
		double a = input.nextDouble();
		System.out.println("请输入矩形的宽：");
		double b = input.nextDouble();
		double s = a*b;
		return s;
	}

	public double roundness(){
		System.out.println("请输入圆形的半径：");
		double r = input.nextDouble();
		double s = r*r*3.14;
		return s;
	}

	public void choose(){
		System.out.println("请输入您要计算面积的形状是：1.三角形 2.矩形 3.圆形");
		int choose = input.nextInt();
		switch(choose){
		case 1 :
			System.out.println("三角形的面积是："+triangle());
			break;
		case 2 :
			System.out.println("矩形的面积是："+rectangle());
			break;
		case 3 :
			System.out.println("圆形的面积是："+roundness());
			break;
		default:
			System.out.println("您输入错误！");
			choose();
		}
	}

	public static void main(String[] args) {
		HomeWork area = new HomeWork();
		area.choose();
	}
}
